package com.bw.Controller;

import com.bw.Service.sugarService;
import com.bw.doman.sugarDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    sugarService sugarService;

    @RequestMapping("/getChinaMpa")
    public Map  getChinaMpa(){
        List<sugarDTO> list = sugarService.getChinaMpa();
        Map map = new HashMap<>();
        map.put("status",0);

       Map map1= new HashMap<>();
       map1.put("mapData",list);
        map.put("data",map1);
        return map;
    }

    /**
     * 品牌展示
     */
    @RequestMapping("/getTrademark")
    public Map getTrademark(){
        List<sugarDTO> list = sugarService.getTrademark();
        List<String> categoriesList = new ArrayList<>();
        List<BigDecimal> seriesList = new ArrayList<>();
        for (sugarDTO sugarDTO : list) {
            categoriesList.add(sugarDTO.getName());
            seriesList.add(sugarDTO.getValue());
        }

        Map map = new HashMap<>();
        map.put("status",0);

        Map categoriesMap = new HashMap<>();
        categoriesMap.put("categories",categoriesList);

        Map map1 = new HashMap<>();
        map1.put("name","品牌");
        map1.put("data",seriesList);
        List list1 =new ArrayList();
        list1.add(map1);

        categoriesMap.put("series",list1);
        map.put("data",categoriesMap);

        return  map;
    }

    /**
     * 销售占比
     */
    @RequestMapping("/getCategory")
    public Map  getCategory(){
        List<sugarDTO> list = sugarService.getCategory();
        Map map = new HashMap<>();
        map.put("status",0);
        map.put("data",list);
        return map;

    }


}
